<%@ page import="cn.edu.njust.service.UserService" %>
<%@ page import="cn.edu.njust.service.impl.UserServiceImpl" %>
<%@ page import="cn.edu.njust.pojo.User" %>
<%@ page import="java.util.List" %>
<%@ page import="cn.edu.njust.service.trService" %>
<%@ page import="cn.edu.njust.service.impl.trServiceImpl" %>
<%@ page import="cn.edu.njust.pojo.Transcipt" %><%--
  Created by IntelliJ IDEA.
  User: NJUST'er'wang's
  Date: 2022/12/2
  Time: 19:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>CCF预报名系统|重置密码</title>

    <!-- Google Font: Source Sans Pro -->
    <link rel="stylesheet"
          href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="./plugins/fontawesome-free/css/all.min.css">
    <!-- DataTables -->
    <link rel="stylesheet" href="./plugins/datatables-bs4/css/dataTables.bootstrap4.min.css">
    <link rel="stylesheet" href="./plugins/datatables-responsive/css/responsive.bootstrap4.min.css">
    <link rel="stylesheet" href="./plugins/datatables-buttons/css/buttons.bootstrap4.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="./dist/css/adminlte.min.css">

    <script src="./js/axios-0.18.0.js"></script>
</head>
<body class="hold-transition sidebar-mini">
<div class="wrapper">
    <!-- Navbar -->
    <nav class="main-header navbar navbar-expand navbar-white navbar-light">
        <!-- Left navbar links -->
        <ul class="navbar-nav">
            <li class="nav-item">
                <a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
            </li>
            <!-- <li class="nav-item d-none d-sm-inline-block">
              <a href="../../index3.html" class="nav-link">Home</a>
            </li> -->
            <!-- <li class="nav-item d-none d-sm-inline-block">
              <a href="#" class="nav-link">Contact</a>
            </li> -->
        </ul>

        <!-- Right navbar links -->
        <ul class="navbar-nav ml-auto">

            <!-- 消息，直接删除 -->

            <!-- 提示，直接删除 -->

            <li class="nav-item">
                <button type="button" class="btn btn-info" onclick="exitRegister()">退出当前登录</button>
            </li>
            <li class="nav-item">
                <a class="nav-link" data-widget="fullscreen" href="#" role="button">
                    <i class="fas fa-expand-arrows-alt"></i>
                </a>
            </li>
        </ul>
    </nav>

    <aside class="main-sidebar sidebar-dark-primary elevation-4">
        <!-- Brand Logo -->
        <a href="javascript:void(0)" class="brand-link">
            <img src="./dist/img/AdminLTELogo.png" alt="CCF预报名系统" class="brand-image img-circle elevation-3"
                 style="opacity: .8">
            <span class="brand-text font-weight-light">CCF预报名系统</span>
        </a>

        <!-- Sidebar -->
        <div class="sidebar">
            <!-- Sidebar Menu -->
            <nav class="mt-2">
                <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu"
                    data-accordion="false">
                    <!-- Add icons to the links using the .nav-icon class
                         with font-awesome or any other icon font library -->
                    <li class="nav-item">
                        <a href="/CCF_Pre_Registration_System/resetPassword.jsp" class="nav-link">
                            <i class="nav-icon fas fa-eraser"></i>
                            <p>重置密码</p>
                        </a>
                    </li>
                    <li class="nav-item">
                        <a href="/CCF_Pre_Registration_System/clearCache.html" class="nav-link">
                            <i class="nav-icon fas fa-exclamation"></i>
                            <p>清除缓存</p>
                        </a>
                    </li>
                </ul>
            </nav>
            <!-- /.sidebar-menu -->
        </div>
        <!-- /.sidebar -->
    </aside>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Main content -->
        <section class="content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-body">
                                <table id="example1" class="table table-bordered table-striped"
                                       style="text-align: center;">
                                    <%
                                        UserService us = new UserServiceImpl();
                                        List<User> users = us.selectAll();
                                    %>

                                    <%-- 表头 --%>
                                    <thead>
                                    <tr>
                                        <th>序号</th>
                                        <th>学生学号</th>
                                        <th>用户名</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                        <%
                                            for (int i = 0; i < users.size(); i++) {
                                                User user = users.get(i);
                                        %>
                                        <tr>
                                            <td><%=i+1%></td>
                                            <td><%=user.getIdNo()%></td>
                                            <td><%=user.getuName()%></td>
                                            <td>

                                                <button type="button" class="btn btn-danger" onclick="delete01(<%=user.getIdNo()%>)"><a href="#"
                                                                                                style="color: white;">删除</a>
                                                </button>
                                                <button type="button" class="btn btn-primary" onclick="reset01(<%=user.getIdNo()%>)"><a href="#"
                                                                                                 style="color: white;">重置密码</a>
                                                </button>

                                            </td>
                                        </tr>
                                        <%
                                            }
                                        %>
                                    </tbody>
                                    <tfoot>
                                    </tfoot>
                                </table>
                            </div>

                            <!-- /.card-body -->
                        </div>
                        <!-- /.card -->
                    </div>
                    <!-- /.col -->
                </div>
                <!-- /.row -->
            </div>
            <!-- /.container-fluid -->
        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->

    <!-- Control Sidebar -->
    <aside class="control-sidebar control-sidebar-dark">
        <!-- Control sidebar content goes here -->
    </aside>
    <!-- /.control-sidebar -->
</div>
<!-- ./wrapper -->

<!-- jQuery -->
<script src="./plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="./plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- DataTables  & Plugins -->
<script src="./plugins/datatables/jquery.dataTables.min.js"></script>
<script src="./plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="./plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="./plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
<script src="./plugins/datatables-buttons/js/dataTables.buttons.min.js"></script>
<script src="./plugins/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
<script src="./plugins/jszip/jszip.min.js"></script>
<script src="./plugins/pdfmake/pdfmake.min.js"></script>
<script src="./plugins/pdfmake/vfs_fonts.js"></script>
<script src="./plugins/datatables-buttons/js/buttons.html5.min.js"></script>
<script src="./plugins/datatables-buttons/js/buttons.print.min.js"></script>
<script src="./plugins/datatables-buttons/js/buttons.colVis.min.js"></script>
<!-- AdminLTE App -->
<script src="./dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="./dist/js/demo.js"></script>
<!-- Page specific script -->
<script>
    function delete01(id) {
        axios({
            method: "post",
            url: "/CCF_Pre_Registration_System/root/deleteById?id="+ id
        }).then(function (resp) {
            if (resp.data === "success") {
                alert("删除成功");
                window.location.href = "/CCF_Pre_Registration_System/resetPassword.jsp"
            } else {
                alert("请重试")
            }
        })
    }
    function reset01(id) {
        axios({
            method: "post",
            url: "/CCF_Pre_Registration_System/root/resetById?id="+ id
        }).then(function (resp) {
            if (resp.data === "success") {
                alert("重置密码成功");
                window.location.href = "/CCF_Pre_Registration_System/resetPassword.jsp"
            } else {
                alert("请重试")
            }
        })
    }
    function clearCache() {
        axios({
            method: "post",
            url: "/CCF_Pre_Registration_System/root/clearCache"
        }).then(function (resp) {
            if (resp.data === "success") {
                alert("清楚缓存成功");

            } else {
                alert("请重试")
            }
        })
    }
</script>
<script>
    $(function () {
        $("#example1").DataTable({
            "responsive": false, "lengthChange": true, "autoWidth": false, "searching": true, "ordering": false
            // "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
        }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
        $('#example2').DataTable({
            "paging": true,
            "lengthChange": false,
            "searching": false,
            "ordering": true,
            "info": true,
            "autoWidth": false,
            "responsive": true,
        });
    });
    function exitRegister(){
        axios({
            method:"post",
            url:"/CCF_Pre_Registration_System/systemControl/exitCurrentLoginUser"
        }).then(function (resp){
            if(resp.data==="success"){
                window.location.href="index.jsp";
            }else {
                alert("请重试");
            }
        })
    }
</script>
</body>
</html>

